﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;

namespace ODM_Code.Forms
{
    public partial class AsciiDumpForm : Form
    {
        esriUtil.rasterUtil ru;

        public AsciiDumpForm()
        {
            InitializeComponent();
            ru = new esriUtil.rasterUtil();
        }

        private void selButton_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            textBox1.Text = openFileDialog1.FileName;
        }

        private void goButton_Click(object sender, EventArgs e)
        {
            string txt = textBox1.Text;
            int endOfPathPos = txt.LastIndexOf("\\");
            int extPos = txt.LastIndexOf(".");
            int nameLen = extPos - endOfPathPos;
            string savePath = txt.Substring(0, endOfPathPos);
            string name = txt.Substring(endOfPathPos + 1, nameLen - 1);

            IRaster ras = ru.returnRaster(txt);

            rUtils.DumpToASCII(ras, savePath, name);
            MessageBox.Show("Done.");
            this.Close();
        }



    }
}
